<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>  
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合同基础信息列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
		<form id="searchBar">
			<div class="fieldset1 clearFix">
				<div class="fieldBox col_33">
					<div class="label">合同名称</div>
					<div class="field">
						<input name="contNm" id="contNm" type="text" class="ui-textbox"/>
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">合同类型</div>
					<div class="field">
						<input type="text" id="contTyp" name="contTyp" ltype="combobox" placeholder="请选择"/>
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">签署节点</div>
					<div class="field">
						<input type="text" id="signNode" name="signNode" ltype="combobox" placeholder="请选择"/>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">合同编码</div>
					<div class="field">
						<input name="contCd" id="contCd" type="text" class="ui-textbox"/>
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">签署方式</div>
					<div class="field">
						<input type="text" id="signWayCd" name="signWayCd" ltype="combobox" placeholder="请选择"/>
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">签署角色</div>
					<div class="field">
						<input type="text" id="signRole" name="signRole" ltype="combobox" placeholder="请选择"/>
					</div>
				</div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round" onclick="searchBtn()">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round" onclick="clearBtn()">清空</span>
                    <span id="addBtn" class="sq-button sq-button-round" onclick="addBtn();">新增</span>
                </div>
			</div>
		</form>
	</div>
	<div id="ligergrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
    $(function () {
    	init();// 初始话选择框
    });
    
    function init(){

		// 初始化合同签署方式
		$.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: "0000", sysCd: "11000",codeGroup:"CONT004" },
				function(json){
					$("#signWayCd").ligerComboBox({
						data: json,
						valueField: 'key',
						textField:'value',
					});
				}
		);
		// 初始化合同类型
		$.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: "0000", sysCd: "11000",codeGroup:"CONT001" },
				function(json){
					$("#contTyp").ligerComboBox({
						data: json,
						valueField: 'key',
						textField:'value',
					});
					if(json && !liger.get("contTyp").getValue()){
						liger.get("contTyp").setValue(json[0].key);
					}
					initGrid();
				}
		);
		// 初始化合同签署节点
		$.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: "0000", sysCd: "11000",codeGroup:"CONT002" },
				function(json){
					$("#signNode").ligerComboBox({
						data: json,
						valueField: 'key',
						textField:'value',
					});
				}
		);
		// 初始化合同签署角色
		$("#signRole").ligerComboBox({
			url:'<%=path%>/system/sysdictionary/getSysDic.do',
			//data: json,
			ajaxType:'GET',
			parms:{ orgCd: "0000", sysCd: "11000",codeGroup:"CONT006" },
			isShowCheckBox: true, 
			isMultiSelect: false,
		    valueField: 'key',
			textField:'value'
		}); 
		<%-- $.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: "0000", sysCd: "11000",codeGroup:"CONT006" },
				function(json){
					$("#signRole").ligerComboBox({
						data: json,
						isMultiSelect: true,
						valueField: 'key',
						textField:'value',
					});
				}
		); --%>

    }

    function initGrid() {
		grid = $("#ligergrid").ligerGrid({
			url: '<%=path%>/cont/config/initList.do',
            parms:function(){
                return $("#searchBar").ligerForm().getData();
            },
			columns: [
				{display: '合同编码', name: 'contCd', enabledSort:true},
				{display: '合同名称', name: 'contNm',  enabledSort:true,
					render:function (rowdata, rowindex, value, column) {
						if(value != null){
							return "<a  href='javascript:void(0)' onclick='toDetail("+rowdata.id+")'>"+value+"</a>";
						}
					}},
				{display: '合同类型', name: 'contTypNm', enabledSort:true},
				{display: '签署节点', name: 'signNodeNm',enabledSort:true},
				{display: '签署方式', name: 'signWayNm',enabledSort:true},
				{display: '签署角色',name:'signRoleNm', enabledSort:true},
				{display: '签署信息',name:'signInfo',enabledSort:true},
				{display: '操作',
					render:function (rowdata, rowindex, value, column) {
						var h = "";
						h+="<a href='javascript:void(0)' onclick='modifyContConfig("+rowdata.id+")'>修改</a>";
						h+="<a class='sq-button-hasicon' href='javascript:void(0)' onclick='delContConfig("+rowdata.id+")'>删除</a>";
						return h;
					}
				}
			],
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            height:'100%',
            heightDiff:-2,
            checkbox:false,//列表是否有选择框
            rownumbers:false//列表是否有行号
		});
	}

	function searchBtn(){
        grid.reload();
	}

	function clearBtn(){
        var form = new liger.get("searchBar");
        form.setData({
			contNm: "",
			contTyp: "",
			signNode: "",
			contCd: "",
			signWayCd:"",
			signRole:""
        });
	}

	function addBtn(){
		var callback = grid.loadServerData(liger.get("searchBar").getData());
		var timestamp=new Date().getTime();
		Add_navTab('tab_base_cont_add'+timestamp,'添加合同信息','<%=path%>/cont/config/toSaveOrDetailPage.do?detailFlag=true', callback);
	}

	function modifyContConfig(id) {
		if (!id) {
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
			return;
		}
		var timestamp=new Date().getTime();
		var callback = grid.reload();
		Add_navTab('tab_base_cont_add'+timestamp,'修改合同信息','<%=path%>/cont/config/toSaveOrDetailPage.do?detailFlag=true&id='+id, callback);
	}

	function toDetail(id){
		var timestamp=new Date().getTime();
		Add_navTab('tab_base_cont_detail'+timestamp,'合同详情信息','<%=path%>/cont/config/toSaveOrDetailPage.do?detailFlag=false&id='+id);
	}

	function delContConfig(id){
		if(!id){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW , SQ_type: "warning" });
			return;
		}
		$.ligerDialog.confirm('确定删除吗?', function () {
			var wait_dialog = null;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:id},
				url: '<%=path%>/cont/config/removeById.do',
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},
				success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
						$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						grid.reload();//刷新
					}else{
						$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					}
				}
			});
		});
	}

</script>

</body>
</html>